-
Notifications
You must be signed in to change notification settings - Fork 139
fix: handle missing parent snapshots in ExpireSnapshots #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: handle missing parent snapshots in ExpireSnapshots #671
Conversation
After snapshot expiration, remaining snapshots may have parent-snapshot-id references pointing to snapshots that no longer exist. ExpireSnapshots was failing when walking the parent chain and encountering these dangling references. Change the behavior to treat a missing parent snapshot as the end of the chain rather than returning an error. This is expected and valid behavior in Iceberg tables that have undergone previous snapshot expiration.
| if err != nil { | ||
| return err | ||
| // Parent snapshot may have been removed by a previous expiration. | ||
| // Treat missing parent as end of chain - this is expected behavior. | ||
| break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we match on the specific error type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twuebi not sure I understand. There's really only one reason SnapshotByID() fails -- when the given snapshot ID doesn't exist in snapshotList list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably goes beyond the scope of this PR, if the only reason for SnapshotByID to ever error is not found, then it should probably become a bool, ptr or simply just ptr interface.
Relying on the function to only return an err for not found means that we rely on something that's not statically checked, although unlikely, someone may change SnapshotByID to return err on other cases too, and we'd treat that as happy path here.
|
Thanks @dhananjaykrutika can you add a test for this? |
@zeroshade done. |
zeroshade
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks much! Just need to resolve the conflicts and i'll merge this
After snapshot expiration, remaining snapshots may have parent-snapshot-id references pointing to snapshots that no longer exist. ExpireSnapshots was failing when walking the parent chain and encountering these dangling references.
Change the behavior to treat a missing parent snapshot as the end of the chain rather than returning an error. This is expected and valid behavior in Iceberg tables that have undergone previous snapshot expiration.